package org.nerve.webmagic.bean;


import java.io.Serializable;
import java.util.List;

/**
 * 页面爬取配置
 * org.nerve.webmagic.processor
 * Created by zengxm on 2016/4/20 0020.
 */
public class SpiderConfig implements Serializable{
	private String name;                        //任务名称
	private String homePage;                    //开始爬取的页面
	private String domain;                      //域名
	private boolean takeScreenshot;             //是否拍照
	private boolean keepScreenData;             //是否保留截图数据（Base64），如果不为true则采集时不会进行截图
	private boolean saveScreenToLocal;          //是否保存截图到本地文件
	private String screenDirectory;             //保存截图的目录（绝对路径）
	private int deep;                           //采集的深度
	private int threadSize;                     //线程数
	private String userAgent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36";                   //默认使用chrome
	private List<KeyValue> headers;
	private List<Cookie> cookies;
	private String charset;                     //字符集
	private int sleepTime=1000;                 //每次爬取的间隔
	private boolean useGzip=true;
	private String proxyHost;                   //代理主机
	private int proxyPort;                      //代理端口
	private String linkRule;                    //采集的链接匹配规则
	private boolean phantomjs;                  //使用phantomjs作为下载器
	private boolean jbrowser;                   //使用JBrowserd
	private boolean loadImages;                 //是否加载图片

	public boolean isTakeScreenshot() {
		return takeScreenshot;
	}

	public SpiderConfig setTakeScreenshot(boolean takeScreenshot) {
		this.takeScreenshot = takeScreenshot;
		return this;
	}

	public boolean isLoadImages() {
		return loadImages;
	}

	public SpiderConfig setLoadImages(boolean loadImages) {
		this.loadImages = loadImages;
		return this;
	}

	public boolean isJbrowser() {
		return jbrowser;
	}

	public SpiderConfig setJbrowser(boolean jbrowser) {
		this.jbrowser = jbrowser;
		return this;
	}

	public boolean isPhantomjs() {
		return phantomjs;
	}

	public SpiderConfig setPhantomjs(boolean phantomjs) {
		this.phantomjs = phantomjs;
		return this;
	}

	public String getLinkRule() {
		return linkRule;
	}

	public SpiderConfig setLinkRule(String linkRule) {
		this.linkRule = linkRule;
		return this;
	}

	public String getProxyHost() {
		return proxyHost;
	}

	public SpiderConfig setProxyHost(String proxyHost) {
		this.proxyHost = proxyHost;
		return this;
	}

	public int getProxyPort() {
		return proxyPort;
	}

	public SpiderConfig setProxyPort(int proxyPort) {
		this.proxyPort = proxyPort;
		return this;
	}

	public boolean isUseGzip() {
		return useGzip;
	}

	public SpiderConfig setUseGzip(boolean useGzip) {
		this.useGzip = useGzip;
		return this;
	}

	public int getSleepTime() {
		return sleepTime;
	}

	public SpiderConfig setSleepTime(int sleepTime) {
		this.sleepTime = sleepTime;
		return this;
	}

	public String getCharset() {
		return charset;
	}

	public SpiderConfig setCharset(String charset) {
		this.charset = charset;
		return this;
	}

	public String getName() {
		return name;
	}

	public SpiderConfig setName(String name) {
		this.name = name;
		return this;
	}

	public String getUserAgent() {
		return userAgent;
	}

	public SpiderConfig setUserAgent(String userAgent) {
		this.userAgent = userAgent;
		return this;
	}

	public List<KeyValue> getHeaders() {
		return headers;
	}

	public SpiderConfig setHeaders(List<KeyValue> headers) {
		this.headers = headers;
		return this;
	}

	public List<Cookie> getCookies() {
		return cookies;
	}

	public SpiderConfig setCookies(List<Cookie> cookies) {
		this.cookies = cookies;
		return this;
	}

	public int getDeep() {
		return deep;
	}

	public SpiderConfig setDeep(int deep) {
		this.deep = deep;
		return this;
	}

	public int getThreadSize() {
		return threadSize;
	}

	public SpiderConfig setThreadSize(int threadSize) {
		this.threadSize = threadSize;
		return this;
	}

	public String getHomePage() {
		return homePage;
	}

	public SpiderConfig setHomePage(String homePage) {
		this.homePage = homePage;
		return this;
	}

	public String getDomain() {
		return domain;
	}

	public SpiderConfig setDomain(String domain) {
		this.domain = domain;
		return this;
	}

	public boolean isKeepScreenData() {
		return keepScreenData;
	}

	public SpiderConfig setKeepScreenData(boolean keepScreenData) {
		this.keepScreenData = keepScreenData;
		return this;
	}

	public boolean isSaveScreenToLocal() {
		return saveScreenToLocal;
	}

	public SpiderConfig setSaveScreenToLocal(boolean saveScreenToLocal) {
		this.saveScreenToLocal = saveScreenToLocal;
		return this;
	}

	public String getScreenDirectory() {
		return screenDirectory;
	}

	public SpiderConfig setScreenDirectory(String screenDirectory) {
		this.screenDirectory = screenDirectory;
		return this;
	}

	public String toProxyString(){
		return proxyHost+":"+proxyPort;
	}
}
